﻿namespace NodeBasedSkillEditor
{
    public class Value_String : AValue
    {
        public override EValueType ValueType { get { return EValueType.String; } }

        public string Value;

        public Value_String(string v)
        {
            Value = v;
        }

        public Value_String(StringPort portData)
        {
            Value = portData.Value;
        }

        public override AValue Clone()
        {
            return new Value_String(Value);
        }

        public override bool SetString(string v)
        {
            Value = v;
            return true;
        }

        public override void Reset()
        {
            Value = null;
        }

        public override void Add(AValue x)
        {
            if (x.ValueType == EValueType.String)
            {
                var y = x as Value_String;
                Value = Value + y.Value;
            }
        }

        public override bool EqualsValue(AValue x)
        {
            if (x.ValueType == EValueType.String)
            {
                var y = x as Value_String;
                return Value == y.Value;
            }
            return false;
        }

        public override string ToString()
        {
            return Value;
        }
    }
}
